package com.cloud.test;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author DELL
 */
@WebServlet(value = {"/Test05","/test05"})
public class ServletTest05 extends HttpServlet {
    /**
     * 该方法可以多次调用，每当收到请求则调用。
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("Service is start.");

    }

    /**
     *
     */
    @Override
    public void destroy() {
        System.out.println("Service is destroy.");

    }

    /**
     * 初始化方法
     * 系统方法，由服务器自动调用
     * 当请求到达servlet容器时，Servlet容器会判断Servlet对象是否存在，如果不存在则创建实例并且初始化
     * 每个生命周期只会执行一次
     *
     * @throws ServletException
     */
    @Override
    public void init() throws ServletException {
        System.out.println("Create a instance...");

    }
}
